/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Portions created by the Initial Developer are
 * Copyright (C) 2012 the Initial Developer.
 * All Rights Reserved.
 *
 * The Original Code is this.
 *
 * The Initial Developer of the Original Code is the author below.
 */
/**
 * @file Semaphore.h
 * @brief auto generated.
 * @author K.Ozaki
 * @date 2011/10/15
 */

#ifndef SEMAPHORE_H_
#define SEMAPHORE_H_

#include <semaphore.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "semi/util/StringUtil.h"

namespace semi {

namespace posix {

class Semaphore {
public:
    Semaphore();
    Semaphore(std::string name);
    virtual ~Semaphore();

    std::string name;
    sem_t* id;

    void init(std::string name);

    bool wait();
    bool post();

    bool open();
    bool close();
    bool unlink();

    int getvalue();

    void postAll();
    void terminate();
};

}
}

#endif /* SEMAPHORE_H_ */
